<?php
/**
 * @desc 充值表数据层
 * @author kevin.wang
 * @date 2015-01-01 12:00:00
 */
class Recharge extends Base
{
	//数据表
	protected $table = 'pert_recharge_log';
	//写入数据
	public function insertRecharge(array $data){
		$table = $this->table;
		return $this->insert_table($data, $table);
	}
	//更改充值记录状态
	public function updateRechargeStatus($status, $tradeId){
		$table = $this->table;
		$sql = "update `{$table}` set `status` = :status where `trade_id` = :trade_id and `status` = 0 and `delete_flag` = 0";
		return $this->update_table($sql, array(':status'=>$status,':trade_id'=>$tradeId));
	}
	//获取充值成功记录
	public function getRechargeLog($tradeId){
		$table = $this->table;
		$sql = "select `user_id`,`order_sn`,`trade_id`,`amount`,`fee`,`account`,`status` from `{$table}` where `trade_id` = :trade_id and `delete_flag` = 0";
		return $this->select_table($sql, array(':trade_id' => $tradeId), Base::QUERY_RAW);
	}
}
